<template>
	<view class="height-screen">
		<cu-custom isBack bgColor="bg-red">
			<block slot="content">{{$t('login.anquan')}}</block>
		</cu-custom>
		<view class="flex flex-direction font-400" style="margin: 25rpx;font-size: 26rpx;color: #222222;">
			<u-parse :content="cancel"></u-parse>
		</view>
		<view class="flex flex-direction" style="position: fixed;left: 25rpx;right: 25rpx;bottom: 30rpx;">
			<view class="flex justify-center" style="font-size: 28rpx;color: #888888;">
				<text @tap="isShowAgree" class="cuIcon"
					:class="showAgree ? 'cuIcon-radiobox' : 'cuIcon-round'">{{$t('login.agree')}}
					<text class="text-blue">《{{$t('login.zhuxiao')}}》</text></text>
			</view>
			<view class="setButton margin-top" style="height: 85rpx;background: #B72928;border-radius: 40rpx;"
				@tap.stop="del_account">
				<text class="text-white font-400" style="font-size: 30rpx;">{{$t('filed.queding')}}</text>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		del_account,
		zhuxiaoxieyi
	} from '@/apis'
	export default {
		data() {
			return {
				showAgree: false,
				cancel: ''
			}
		},
		onShow() {
			this.zhuxiaoxieyi()
		},
		methods: {
			async zhuxiaoxieyi() {
				const res = await zhuxiaoxieyi()
				this.cancel = res
			},
			isShowAgree() {
				this.showAgree = !this.showAgree;
			},
			async del_account() {
				if (!this.showAgree) {
					this.helper.showToast(this.$t('message.warning'))
				} else {
					await del_account()
					this.helper.showToast(this.$t('message.success'))
					this.helper.removeStorageSync('token')
					setTimeout(() => {
						this.helper.routerNav('/pages/tabBar/login')
					}, 1000)
				}
			}
		}
	}
</script>

<style>
</style>